package sb.de.advanceShopper.dataBase;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class CitiesSQLiteHelper extends SQLiteOpenHelper {
	
	private static final int DB_VER = 1;
	private static final String DB_NAME = "adv_shopper.db";
	public static final String CITIES_TABLE = "cities";

	//columns
	public static final String CITIES_TCID = "_id";
	public static final String CITIES_TCNAME = "name";
	public static final String CITIES_TCCOUNTRY = "country";

	public static final String CITIES_TCREATE = "CREATE TABLE "
			+ CITIES_TABLE + " (" + CITIES_TCID
			+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + CITIES_TCNAME
			+ " TEXT NOT NULL, " + CITIES_TCCOUNTRY + " INTEGER NOT NULL);";

	public static final String CITIES_SELECT_ALL = "SELECT * FROM " + DB_NAME
			+ "." + CITIES_TABLE + ";";

	public CitiesSQLiteHelper(Context context) {
		super(context, DB_NAME, null, DB_VER);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CITIES_TCREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(CitiesSQLiteHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + CITIES_TABLE);
		onCreate(db);
	}

}